#ifndef __GLF_CORE_ASSERT_H_INCLUDED__
#define __GLF_CORE_ASSERT_H_INCLUDED__

#include <glf/config.h>

namespace glf {

enum AssertBehavior {
	ASSERT_DONOTHING,
	ASSERT_IGNORE_ALWAYS,
	ASSERT_IGNORE_THIS_TIME,
	ASSERT_BREAK
};

extern bool gIsAssertEnabled;

#if GLF_AS_DLL

void SetIsAssertEnabled(bool isEnable);
bool IsAssertEnabled();

#else

inline void SetIsAssertEnabled(bool isEnable) {gIsAssertEnabled = isEnable;}
inline bool IsAssertEnabled() {return gIsAssertEnabled;}

#endif

AssertBehavior Assert(const char *file, int line, const char *fmt, ... );

} //namespace glf

#if GLF_USE_ASSERT
	#define GLF_ASSERTMSG(x, ...) \
		{ \
			static bool isIgnoreAssert = false; \
			if(!isIgnoreAssert && !(x) && glf::IsAssertEnabled()) \
			{ \
				glf::AssertBehavior	ab = glf::Assert(__FILE__, __LINE__, __VA_ARGS__); \
				if(ab == glf::ASSERT_IGNORE_ALWAYS) { \
					isIgnoreAssert = true;  \
				} else if(ab == glf::ASSERT_BREAK) { \
					GLF_BREAKPOINT(); \
				} \
			} \
		}
	#define GLF_ASSERT_ONLY(stuff) stuff
#else
	#define GLF_ASSERTMSG(x, ...)
	#define GLF_ASSERT_ONLY(stuff) 
#endif

#if GLF_USE_ASSERT

#define GLF_ASSERT(x)	GLF_ASSERTMSG(x, #x)
#define GLFi_ASSERT(x)	GLF_ASSERTMSG(x, #x)

#else

#define GLF_ASSERT(x)
#define GLFi_ASSERT(x)

#endif

#define GLF_CHECK_RANGE(idx, arr) GLF_ASSERT(idx >= 0 && idx < GLF_ASIZEOF(arr))


#endif
